<?php


namespace app\api\controller;


use app\common\service\TokenService;

class Token extends ApiBase
{
    /**
     * 获取token
     * @return \think\response\Json
     */
    public function getAccessToken()
    {
        $token = new TokenService(['type' => 'ap', 'conValue' => '']);
        $data = ["appkey" => "511375e50b18d34b1590be2edaf0f7a2", "secret" => "admin888", 'refresh' => true];
        $access_token = $token->createAccessToken($data);
        return $this::returnData($access_token);
    }

    /**
     * 刷新token时间
     * @return \think\response\Json
     */
    public function refreshAccessToken()
    {
        $token = new TokenService(['type' => 'ap', 'conValue' => '']);
        $data = [
            "appkey"        => "511375e50b18d34b1590be2edaf0f7a2",
            "secret"        => "admin888",
            "token"         => '515834818065135419694AAAC6C93E0C',
            'refresh_token' => '91010319E111CE45D70C97184430DB12',
        ];
        $access_token = $token->refreshToken($data);
        return $this::returnData($access_token);
    }

    /**
     * 验证dataSign
     * @return \think\response\Json
     */
    public function checkDataSign()
    {
        $token = new TokenService(['type' => 'ap', 'conValue' => '']);
        $data = [
            "token"         => '515834818065135419694AAAC6C93E0C',
            'refresh_token' => '91010319E111CE45D70C97184430DB12',
            'dataSign'      => ''
        ];
        $access_token = $token->checkDataSign($data);
        return $this::returnData($access_token);
    }
}